﻿using RuoVea.ExDto;
using SqlSugar;

namespace Gantt.Server.Dto;

/// <summary>
/// 
/// </summary>
public class TasksPageParam : PageParam
{
    /// <summary>
    /// 项目Id
    /// </summary>
    public long ProjectId { get; set; }
}
/// <summary>
/// 任务列表模型
/// </summary>
public class TasksModel
{
    /// <summary>
    /// 项目Id
    /// </summary>
    public long ProjectId { get; set; }
    /// <summary>
    /// 任务的唯一标识符
    /// </summary>
    public long id { get; set; }

    /// <summary>
    /// 任务的名称
    /// </summary>
    public string? label { get; set; }

    /// <summary>
    /// 任务分配给的用户
    /// </summary>
    public string? user { get; set; }

    /// <summary>
    /// 父任务的ID，如果是子任务的话
    /// </summary>
    public long? parentId { get; set; }

    /// <summary>
    /// 任务开始的时间
    /// </summary>
    public DateTime start { get; set; }

    /// <summary>
    /// 任务结束的时间
    /// </summary>
    public DateTime end { get; set; }

    /// <summary>
    /// 任务持续的时间（例如天数）
    /// </summary>
    public long? duration { get; set; }

    /// <summary>
    /// 任务完成的百分比（乘以100）
    /// </summary>
    public int? percent { get; set; }

    /// <summary>
    /// 类别ID
    /// </summary>
    public long typeId { get; set; }
    /// <summary>
    /// 类别code
    /// </summary>
    public string? type { get; set; }
    /// <summary>
    /// 任务进度（与percent可能类似，但用途略有不同）
    /// </summary>
    public int? progress { get; set; }

    /// <summary>
    /// 是否展开（有子目录时才需要设置）
    /// </summary>
    public bool? collapsed { get; set; }



 
    /// 工期，结束时间减少开始时间，单位是天
    public long? DurationDays { get; set; }


    /// <summary>
    /// 紧前任务（依赖的任务ID）
    /// </summary>
    public long? dependentOns { get; set; }

    public DateTime[] ganttTime { get { return new DateTime[] {start,end }; } }
    /// <summary>
    /// 获取紧前任务的列表
    /// </summary>
    public List<long>? dependentOn
    {
        get
        {
            return new List<long> { dependentOns ?? 0 };
        }
    }

    /// <summary>
    /// 任务的颜色标识
    /// </summary>
    public string? Color { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public long StatusId { get; set; }
    /// <summary>
    /// 任务开始时的名称
    /// </summary>
    public string? StatusName { get; set; }

    /// <summary>
    /// 任务开始时的颜色标识
    /// </summary>
    public string? StatusColor { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public long LevelId { get; set; }
    /// <summary>
    /// 任务优先级的名称
    /// </summary>
    public string? LevelName { get; set; }

    /// <summary>
    /// 任务优先级的颜色标识
    /// </summary>
    public string? LevelColor { get; set; }

    /// <summary>
    /// 获取任务的样式模型
    /// </summary>
    public StyleModel style
    {
        get
        {
            return new StyleModel
            {
                @base = new BaseModel
                {
                    fill = Color,
                    //stroke = Color,
                }
            };
        }
    }
}

/// <summary>
/// 样式模型
/// </summary>
public class StyleModel
{
    /// <summary>
    /// 样式的基部分
    /// </summary>
    public BaseModel? @base { get; set; }
}

/// <summary>
/// 基本样式模型
/// </summary>
public class BaseModel
{
    /// <summary>
    /// 填充颜色
    /// </summary>
    public string? fill { get; set; }

    /// <summary>
    /// 边框颜色
    /// </summary>
    public string? stroke { get; set; }
}
